package com.apex.aolonfitdemo.ui;

import android.Manifest;
import android.os.Bundle;
import android.util.Log;
import android.view.View;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;


import com.apex.aolonfit.AolonFitManager;
import com.apex.aolonfitdemo.R;
import com.apex.aolonfitdemo.databinding.ActivityAddContactBinding;
import com.apex.aolonfitdemo.databinding.ActivitySosContactBinding;
import com.apex.ax_bluetooth.callback.GeneralCallback;
import com.apex.ax_bluetooth.core.EABleManager;
import com.apex.ax_bluetooth.model.EABleContact;
import com.cyber.bridge.module.bean.ContactPersonEntity;
import com.cyber.bridge.module.listener.OnCyberContactListener;

import java.util.ArrayList;
import java.util.List;


public class AddContactActivity extends AppCompatActivity {
    private final String TAG = this.getClass().getSimpleName();
    ActivityAddContactBinding activityAddContactBinding;
    int maxCount;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        activityAddContactBinding = ActivityAddContactBinding.inflate(getLayoutInflater());
        setContentView(activityAddContactBinding.getRoot());
        activityAddContactBinding.tool.setNavigationIcon(R.mipmap.exit_page);
        setSupportActionBar(activityAddContactBinding.tool);
        getSupportActionBar().setTitle(null);
        activityAddContactBinding.tool.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        AolonFitManager.getInstance().setOnContactListener(new OnCyberContactListener() {
            @Override
            public void sendContactList(boolean b) {

            }

            @Override
            public void deleteContact(boolean b) {


            }

            @Override
            public void deleteAllContact(boolean b) {

            }

            @Override
            public void queryContactMaxCount(int i) {
                maxCount = i;

            }
        });
        AolonFitManager.getInstance().queryContactMaxCount();
        activityAddContactBinding.submit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                new Thread() {
                    @Override
                    public void run() {
                        super.run();
                        List<ContactPersonEntity> entityList = new ArrayList<>();
                        for (int i = 0; i < 20; i++) {
                            entityList.add(new ContactPersonEntity("zhangsan " + i, "1789654321" + i, i));
                        }
                        AolonFitManager.getInstance().sendContactList(entityList);
                    }
                }.start();
            }
        });
        activityAddContactBinding.deleteAll.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                AolonFitManager.getInstance().deleteAllContact();
            }
        });
    }
}
